local zishucup__jingfan = fk.CreateSkill{
  name = "zishucup__jingfan",
  tags = { Skill.Compulsory },
  dynamic_desc = function(self, player)
    local mark = player:getMark("@@zishucup__jingfan")
    if mark > 0 then
      return "锁定技，（一名角色）的准备阶段，若你有红色牌，你重铸至少一张红色牌，"..
        "否则你展示手牌，令当前回合角色摸三张牌，复原本技能。"
    end
    return "zishucup__jingfan"
  end,
}

Fk:loadTranslationTable{
  ["zishucup__jingfan"] = "惊帆",
  [":zishucup__jingfan"] = "锁定技，（你）的准备阶段，若你有红色牌，你重铸至少一张红色牌，将（）的描述改为“一名角色”；否则你展示手牌，令当前回合角色摸三张牌，复原本技能。",

  ["@@zishucup__jingfan"] = "惊帆 皆发",
  ["#zishucup__jingfan-recast"] = "惊帆：重铸至少一张红色牌，且其他角色的准备阶段你也将触发本技能！",

  ["$zishucup__jingfan1"] = " ",
  ["$zishucup__jingfan2"] = " ",
}

zishucup__jingfan:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    local mark = player:getMark("@@zishucup__jingfan")
    return (mark > 0 or target == player) and player:hasSkill(zishucup__jingfan.name) and target.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local draw = true
    if #table.filter(player:getCardIds("he"), function(id) return Fk:getCardById(id).color == Card.Red end) > 0 then
      draw = false
    end
    if draw then
      if not player:isKongcheng() then
        player:showCards(player:getCardIds("h"))
      end
      if not target.dead then
        target:drawCards(3, zishucup__jingfan.name)
      end
      room:setPlayerMark(player, "@@zishucup__jingfan", 0)
    else
      local bas = room:askToCards(player, {
        min_num = 1,
        max_num = 999,
        pattern = ".|.|heart,diamond",
        include_equip = true,
        skill_name = zishucup__jingfan.name,
        prompt = "#zishucup__jingfan-recast",
        cancelable = false,
      })
      room:setPlayerMark(player, "@@zishucup__jingfan", 1)
      room:recastCard(bas, player, zishucup__jingfan.name)
    end
  end,
})

return zishucup__jingfan
